<!-- 编辑弹窗 -->
<template>
    <div class="ele-body">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" >
        <el-card  >  
          <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
            <div style="width: 48%;" >基础信息</div>
            <div style="width: 52%;display: flex;justify-content:end;" >
              <div style="width: 20%;color:var(--color-primary)" >制单人:{{ form.operatorName }}</div>
              <!-- <div v-show="form.outOrderNo!='' && form.outOrderNo!=null" style="width: 32%;color:var(--color-primary)" >销售出库单号:{{ form.outOrderNo }}</div> -->
            </div>
          </div>      
          <el-row :gutter="24">
            <el-col :md="6" :sm="24">
              <el-form-item label="出库单号:" prop="outOrderNo" :rules="!this.chooseSaleOrder?rules.outOrderNo:rules.outOrderNoIsNull" >
                <el-input v-model="form.outOrderNo" placeholder="调订单时则系统按订单号生成"  :disabled="this.chooseSaleOrder"  />
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24">
              <el-form-item label="客户名称:" prop="customerId">
                <el-select  v-model="form.customerId" filterable clearable placeholder="请选择客户" style="width:100%" :disabled="this.chooseSaleOrder" >
                  <el-option  v-for="item in customerDatas" :key="item.id" :label="item.name" :value="item.id"/>
              </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24">
              <el-form-item label="调订单:" >
                <el-input v-model="form.orderNo" placeholder="请选择销售订单" @focus="OpenSaleOrder" :disabled="this.chooseSaleOrder" >
                  <el-button slot="append" icon="el-icon-search" @click="OpenSaleOrder"></el-button>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24" >
              <el-form-item label="制单日期:"  prop="orderDate">
                <el-date-picker v-model="form.orderDate" type="date" :disabled="this.chooseSaleOrder"  placeholder="请输入制单日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%"  />
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24">
              <el-form-item label="币种:" prop="currencyId">
                <el-select  v-model="form.currencyId" filterable placeholder="请选择币种" style="width:100%" @change="changeCurrencyRate" :disabled="this.chooseSaleOrder" >
                  <el-option  v-for="item in currencyDatas" :key="item.id" :label="item.name" :value="item.id"/>
              </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24">
              <el-form-item label="汇率:" prop="rate">
                <el-input v-model="form.rate" placeholder="请输入汇率"  @change="setRate" :disabled="this.chooseSaleOrder" />
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="24">
              <el-form-item label="发货仓库:" >
                <el-select  v-model="form.warehouseId" filterable clearable placeholder="请选择发货仓库" style="width:100%" :disabled="this.chooseSaleOrder" >
                  <el-option v-for="item in wareHouseDatas" :key="item.id" :label="item.name" :value="item.id"/>
              </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="24" :sm="24" >
              <el-form-item label="备注:"  >
                <el-input :rows="1"
                    clearable
                    type="textarea"
                    :maxlength="200"
                    v-model="form.remark"
                    placeholder="请输入备注说明" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <el-card  style="margin-top: 10px">
          <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
            <div style="width: 8%;" >产品列表</div>
            <div style="width: 92%;display: flex;justify-content:start;" >
              <div style="width: 100%;color:var(--color-primary)" > 
                <el-button type="primary" class="ele-btn-icon" icon="el-icon-plus" v-show="!this.chooseSaleOrder" style="width: 10%;" @click="OpenProductList"  v-permission="'SaleOutOrder_List_Add'">选择产品 </el-button>
              </div>
            </div>
          </div> 
          <el-table :data="form.items" ref="items"  :border="true" style="width: 100%"  :height="tableHeight" :full-height="tableFullHeight" show-summary :summary-method="getSummaries"  :cell-style="cellStyle">
            <el-table-column type="index" width="50" align="center" label="序号" fixed='left' />
            <el-table-column label="批次号" align="center"  width="100"  prop="batchNo" sortable >
            <template slot-scope="{ row }">
              <span>{{ row.batchNo?row.batchNo:'无' }}</span>
            </template>
          </el-table-column>
            <el-table-column label="产品编号"   align="center"  width="150" prop="productCode" sortable>
                <template slot-scope="{ row }">
                  <el-form-item label-width="10" style="margin-bottom:0;" >
                    <span>{{ row.productCode }}</span>
                  </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="产品名称"   align="center"  width="150" prop="productName" sortable>
                <template slot-scope="{ row }">
                  <el-form-item label-width="10" style="margin-bottom:0;" >
                    <span>{{ row.productName }}</span>
                  </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="规格" align="center"   width="100" prop="spc" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.spc }}</span>
              </template>
            </el-table-column>
            <el-table-column label="单位" align="center"  width="80" >
                <template slot-scope="{ row }">
                  <span>{{ row.unitDesc }}</span>
                </template>
            </el-table-column>
            <el-table-column label="数量" align="center"  width="100" prop="qty" sortable>
              <template slot-scope="{row,$index}">
                <el-form-item label-width="10" style="margin-bottom:0;" :prop="'items.'+ $index+'.qty'" :rules="itemRules.qty" >
                  <el-input v-model="row.qty"  placeholder="请输入数量" @change="setAmount(row,$index)"  @keyup.native="row.qty = row.qty.replace(/[^\d.]/g,'');
                    row.qty = row.qty.replace(/\.{2,}/g,'.');
                    row.qty = row.qty.replace(/^\./g,'');
                    row.qty = row.qty.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                    row.qty = row.qty.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');" />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="单价" align="center"  width="120" prop="price" sortable>
                <template slot-scope="{row,$index}">
                  <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.price'" :rules="itemRules.price">
                    <el-input v-if="row.isEdit"  v-model="row.price"  placeholder="请输入单价"  @change="setAmount(row,$index)" @keyup.native="row.price = row.price.replace(/[^\d.]/g,'');
                    row.price = row.price.replace(/\.{2,}/g,'.');
                    row.price = row.price.replace(/^\./g,'');
                    row.price = row.price.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                    row.price = row.price.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" />
                    <span v-else>{{ row.price }}</span>
                  </el-form-item>
                </template>
            </el-table-column>
            <el-table-column label="金额" align="center"  width="140" prop="amount" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.amount }}</span>
              </template>
            </el-table-column>
            <el-table-column label="单价(￥)" align="center"  width="120" prop="priceCn" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.priceCn }}</span>
              </template>
            </el-table-column>
            <el-table-column label="金额(￥)" align="center"  width="140" prop="amountCn" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.amountCn }}</span>
              </template>
            </el-table-column>
            <el-table-column label="发货仓库" align="center" width="150"  prop="deliveryWareHouseId" sortable>
              <template slot-scope="{ row ,$index }">
                <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.deliveryWareHouseId'" :rules="itemRules.deliveryWareHouseId">
                  <el-select :disabled="!row.isEdit"   filterable v-model="row.deliveryWareHouseId" placeholder="请选择发货仓库" class="ele-fluid" >
                    <el-option v-for="item in wareHouseDatas" :key="item.id" :label="item.name" :value="item.id" />
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="提成类型" align="center" width="150" prop="commissionName" sortable >
              <template slot-scope="{ row }">
                <el-form-item label-width="10" style="margin-bottom:0;" >
                  <span>{{ row.commissionName }}</span>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="金额/比例" align="center"  width="120" prop="scale" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.scale?row.scale:'无' }}</span>
              </template>
            </el-table-column>
            <el-table-column label="提成金额" align="center"  width="120" prop="commissionAmount" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.commissionAmount }}</span>
              </template>
            </el-table-column>
            <el-table-column label="提成金额(￥)" align="center"  width="140" prop="commissionAmountCn" sortable>
              <template slot-scope="{ row }">
                <span>{{ row.commissionAmountCn }}</span>
              </template>
            </el-table-column>
            <el-table-column label="行备注" align="center" width="150" >
              <template slot-scope="{ row }">
                <el-input  v-model="row.remarks" placeholder="请输入行备注" />
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center"  width="80" :resizable="false" v-if="!this.chooseSaleOrder" fixed='right' >
              <template slot-scope="{ row , $index}">
                <span class="ele-action">
                  <el-link v-permission="'SaleOutOrder_List_Delete'" v-show="row.isEdit" icon="el-icon-delete" type="danger" :underline="false" @click="remove(row, $index)" >删除</el-link>
                </span>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card  style="margin-top: 10px">
        <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
          <div style="width: 8%;" >预收款</div>
          <div style="width: 92%;display: flex;justify-content:start;" >
            <div style="width: 100%;color:var(--color-primary)" > 
                <el-button type="primary" v-show="!this.chooseSaleOrder" class="ele-btn-icon" icon="el-icon-plus"  style="width: 10%;" @click="OpenPrereviceItemList"  v-permission="'SaleOutOrder_PreList_Add'">选择预收款</el-button>
              </div>
          </div>
        </div> 
        <el-table :data="form.prerevices" ref="prerevices"  :border="true" style="width: 100%" :height="tableHeightPre" :full-height="tableFullHeightPre"  show-summary :summary-method="getSummariesPre"  :cell-style="cellStylePre">
          <el-table-column type="index" width="50" align="center" label="序号" fixed='left' />
          <el-table-column label="批次号" align="center" >
            <template slot-scope="{ row }">
              <span>{{ row.batchNo }}</span>
            </template>
          </el-table-column>
          <el-table-column label="日期"   align="center" prop="reviceDate"   :formatter="dateFormat" >
          </el-table-column>
          <el-table-column label="金额"   align="center"  >
              <template slot-scope="{ row }">
                <el-form-item label-width="10" style="margin-bottom:0;" >
                  <span>{{ row.amount }}</span>
                </el-form-item>
              </template>
          </el-table-column>
          <el-table-column label="币种" align="center"   width="100">
            <template slot-scope="{ row }">
              <span>{{ row.currencyDesc }}</span>
            </template>
          </el-table-column>
          <el-table-column label="收款账户" align="center"  >
              <template slot-scope="{ row }">
                <span>{{ row.bankAccountDesc }}</span>
              </template>
          </el-table-column>
          <el-table-column label="客户名称" align="center">
            <template slot-scope="{ row }">
              <span>{{ row.customerName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="单号" align="center" >
            <template slot-scope="{ row }">
              <span>{{ row.preNum }}</span>
            </template>
          </el-table-column>
          
          <el-table-column label="备注" align="center" prop="remark">
            <!-- <template slot-scope="{ row }">
              <el-input  v-model="row.remark" placeholder="请输入行备注" />
            </template> -->
          </el-table-column>
          <el-table-column label="操作" align="center" width="100" :resizable="false" v-if="!this.chooseSaleOrder" fixed='right' >
            <template slot-scope="{ row , $index}">
              <span class="ele-action">
                <el-link v-permission="'SaleOutOrder_PreList_Delete'" icon="el-icon-delete" type="danger" :underline="false" @click="removePre(row, $index)" >删除</el-link>
              </span>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
        <el-card shadow="never"> </el-card>
        <div class="ele-dailog-bottom" >
          <div class="left" style="display: flex;width: 60%;">
            <el-form-item label="合计:" style="margin-top: 20px;">
              <span class="moneycolor moneyxh" >{{ form.orderAmount }}</span>
            </el-form-item>
            <el-form-item label="优惠金额:" style="margin-top: 20px;" label-width="80px">
              <el-input  v-model="form.disAmount"  placeholder="请输入优惠金额" @change="setRecAmount" style="width:80px;border:0" @keyup.native="form.disAmount = form.disAmount.replace(/[^\d.]/g,'');
                      form.disAmount = form.disAmount.replace(/\.{2,}/g,'.');
                      form.disAmount = form.disAmount.replace(/^\./g,'');
                      form.disAmount = form.disAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                      form.disAmount = form.disAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" ></el-input>  
              <span v-show="this.form.status==15" class="moneycolor moneyxh">{{ form.disAmount }}</span>
            </el-form-item>
            <el-form-item label="收款账户:" style="margin-top: 20px;" prop="bankAccountId" label-width="82px">
              <el-select :disabled="this.chooseSaleOrder"  v-model="form.bankAccountId" filterable clearable placeholder="请选择收款账户" style="width:100px"  @change="changeBank" >
                <el-option v-for="item in bankAccountDatas" :key="item.id" :label="item.name" :value="item.id"/>
              </el-select>
            </el-form-item>
            <el-form-item label="收款金额:" style="margin-top: 20px;" prop="recAmount" label-width="82px">
              <el-input :disabled="this.chooseSaleOrder"   v-model="form.recAmount"  placeholder="请输入收款金额" @change="checkAmount" @blur="checkAmount"  style="width:80px" @keyup.native="form.recAmount = form.recAmount.replace(/[^\d.]/g,'');
                form.recAmount = form.recAmount.replace(/\.{2,}/g,'.');
                form.recAmount = form.recAmount.replace(/^\./g,'');
                form.recAmount = form.recAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                form.recAmount = form.recAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" >
              </el-input>
            </el-form-item>
            <el-form-item label="预收款:" style="margin-top: 20px;"  label-width="60px">
              <el-input  v-model="form.preAmount" disabled   placeholder="请输入预收款" @change="checkAmount"  style="width:80px" @keyup.native="form.preAmount = form.preAmount.replace(/[^\d.]/g,'');
                  form.preAmount = form.preAmount.replace(/\.{2,}/g,'.');
                  form.preAmount = form.preAmount.replace(/^\./g,'');
                  form.preAmount = form.preAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                  form.preAmount = form.preAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" ></el-input> 
            </el-form-item>
            <el-form-item label="实际应收:" style="margin-top: 20px;"  label-width="80px">
              <el-input v-model="form.actAmount" disabled style="width:80px" ></el-input>
            </el-form-item>
          </div>
          <div class="right" style="width: 24%;">
            <el-form-item style="margin-top: 20px" label-width="1px">
              <el-button type="primary" v-show="this.isUpdate!=3 &&  form.outStatus!=5" :loading="loading"   @click="save" v-permission="'SaleOutOrder_Save'">挂单</el-button>
              <el-button type="warning" v-show="this.isUpdate!=3 &&  form.outStatus!=5" :loading="loadingAudit"   @click="audit" v-permission="'SaleOutOrder_Audit'" >过账</el-button>
              <el-button type="danger" v-show="form.outStatus==5"  @click="unAudit" :loading="loadingUnAudit"   v-permission="'SaleOutOrder_UnAudit'" >
                反过账
              </el-button>
              <!-- <el-button type="info" @click="print"  v-show="form.status>=0">打印</el-button> -->
              <el-button  @click="handleClose">关闭</el-button>
            </el-form-item>
          </div>
        </div>
      </el-form>
      <!-- 编辑弹窗 -->
      <productList :visible.sync="showProductList"  @callback="reloadItemList"/>
      <!-- 编辑弹窗 -->
      <saleorderList :visible.sync="showSaleOrderList"  @callback="reloadSaleOrder" />

      <prereviceitemList :data="current" :visible.sync="showPrereviceItemList"  @callback="reloadPrereviceItemList"/>
  </div>
  </template>
  <script>
   import moment from 'moment';
   import { printHtml } from 'ele-admin';
   import { getUser } from '@/utils/user-util';
   import upload from "@/components/UpLoad/index.js";
   import productList from '../components/product-list.vue';
   import saleorderList from '../components/saleorder-list.vue';
   import prereviceitemList from '../../saleordermanager/components/prereviceitem-list.vue';
   import { GetAllAccount } from '@/api/usermanager/accountmanager';
   import { GetAllBackAccount } from '@/api/basicdatamanager/bankaccount';
   import { QueryCustomerPageList } from '@/api/basicdatamanager/customer';
   import { GetAllWarehouse } from '@/api/basicdatamanager/warehousemanager';
   import { QueryAllChildDictViewByCode } from '@/api/systemmanager/dictmanager';
   import { QueryModelByScurrencyId } from '@/api/basicdatamanager/ratemanager';
   import { GetAllBSupplier} from '@/api/basicdatamanager/supplier';
   import { QueryPrereceivePageList} from '@/api/finance/prereceive';
   import { QueryCommissionTypeEnum} from '@/api/enummanger';
   import { QueryCommissionPageList,QueryCommissionByProductTypeId,QueryCommissionBySaleQty} from '@/api/basicdatamanager/commissionplan';
   import { AddSaleoutorder, UpdateSaleoutorder,QuerySaleoutorderById,AuitSaleoutorder,CheckStock,CheckOutQty,PrintSaleOutOrderById,AntiSaleoutorder } from '@/api/businesshandling/saleoutmanger';
   import { removePageTab, reloadPageTab,setPageTabTitle } from '@/utils/page-tab-util';


   export default {
      name: 'SaleOutOrderEdit',
      props: {
        // 弹窗是否打开
        visible: Boolean,
        // 修改回显的数据
        data: Object,
        // 按钮索引
        btnIndex:String,
      },
      mixins: [upload],
      components: {productList,saleorderList,prereviceitemList},
      data() {
        return {
          // 表单数据
          form: {operatorId:'',orderDate:'',disAmount:0,orderAmount:0,recAmount:0,preAmount:0,actAmount:0,items:[{isEdit:true}]},
          fixedHeight:true,
          // 表单验证规则
          rules: {
            outOrderNo: [{required: true,message: '请销售出库单号',trigger: 'blur'}],
            customerId: [{required: true,message: '请选择客户',trigger: 'blur'}],
            deliveryDate: [{required: true,message: '请输入交货日期',trigger: 'blur'}],
            currencyId: [{required: true,message: '请选择币种',trigger: 'blur'}],
            rate: [{required: true,message: '请输入汇率',trigger: 'blur'}],
            warehouseId: [{required: true,message: '请输入发货仓库',trigger: 'blur'}],
            orderDate: [{required: true,message: '请输入制单日期',trigger: 'blur'}],
            // bankAccountId:[{required: true,message: '请输入收款账户',trigger: 'blur'}],
            // recAmount:[{required: true,message: '请输入收款金额',trigger: 'blur'}],

            outOrderNoISNULL: [{required: false}],
            bankAccountId:null,
            recAmount:null,
          },
          itemRules: {
            qty: [{required: true,message: '请输入数量',trigger: 'blur'}],
            price: [{required: true,message: '请输入单价',trigger: 'blur'}],
            deliveryWareHouseId: [{required: true,message: '请输入发货仓库',trigger: 'blur'}],
          },
         
          isShow:false,
          current:null,
          // 提交状态
          loading: false,
          loadingAudit: false,
          loadingUnAudit: false,
          isUpdate: 1,
          saleoutorderId:'',
          computeDirection:2,//默认奈拉
          chooseSaleOrder:false,
          preamount:0,
          // 是否是修改
          showProductList:false,
          showSaleOrderList:false,
          showPrereviceItemList:false,
          defaultDate:new Date(),
          accountDatas:[],
          currencyDatas:[],
          wareHouseDatas:[],
          customerDatas:[],
          commissionDatas:[],
          bankAccountDatas:[],
          commissionTypeDatas:[],
        };
      },
      computed: {
        // 表格高度
        tableHeight() {
          var fh = this.fixedHeight ? 'calc(100vh - 350px)' : void 0;

          return fh;
        },
        // 表格全屏时高度
        tableFullHeight() {
          var fh =  this.fixedHeight ? 'calc(100vh - 286px)' : null;

          return fh;
        },

         // 表格高度
         tableHeightPre() {
          var fh = this.fixedHeight ? 'calc(100vh - 500px)' : void 0;

          return fh;
        },
        // 表格全屏时高度
        tableFullHeightPre() {
          var fh =  this.fixedHeight ? 'calc(100vh - 450px)' : null;

          return fh;
        },
      },
      //初始化数据
      mounted(){
        if(this.isUpdate == 2 || this.isUpdate == 3){
          this.setData(this.saleoutorderId);
        }else if(this.isUpdate == 1){
          this.$refs['form'].clearValidate();
          this.form={operatorId:'',operatorName:'',orderDate:'',orderAmount:0,disAmount:0,recAmount:0,preAmount:0,actAmount:0,items:[]};
          this.isUpdate = 1;
          let currentUser = getUser();
          this.$set(this.form,'orderDate',this.defaultDate);
          this.$set(this.form,'operatorId',currentUser.accountId);
          this.$set(this.form,'operatorName',currentUser.accountName);
          this.setDefaultCurreny();
        }
      },
      created(){
        this.initData();
        this.isUpdate = this.$route.query.isUpdate;
        this.saleoutorderId = this.$route.query.saleoutorderId;
        if(this.isUpdate == 1)  setPageTabTitle('添加销售出库单');
        if(this.isUpdate == 2)  setPageTabTitle('修改销售出库单');
        if(this.isUpdate == 3)  setPageTabTitle('查看销售出库单');
      },
      methods: {

        /* 初始化数据 */
        async initData(){

          GetAllAccount().then((res)=>{
            this.accountDatas = [];
            this.accountDatas = res;
          });

          GetAllBSupplier().then((res)=>{
            this.supplierDatas = [];
            this.supplierDatas = res;
          });

          GetAllWarehouse().then((res)=>{
            this.wareHouseDatas = [];
            this.wareHouseDatas = res;
          });

          GetAllBackAccount().then((res)=>{
            this.bankAccountDatas = [];
            this.bankAccountDatas = res;
          });

          QueryAllChildDictViewByCode(this.Constant.C_HB).then((res)=>{
            this.currencyDatas = [];
            this.currencyDatas = res;
          });

          QueryCommissionTypeEnum().then((res)=>{
            res.map(e=>{
              this.commissionTypeDatas.push({Key:e.Key,Value:e.Value});
            });
          });


          let params = {
              pageindex: 1,
              pagesize: 100000,
              conditions: [],
              orderBys: [{ sort: "createDate", order: 1, }],
            };

          params.conditions.push({
            key:"deleted",
            operator: 0,
            value: 0,
          });

          let result = await QueryCustomerPageList(params);
          this.customerDatas=[];
          this.customerDatas = result.items;

          let commissions = await QueryCommissionPageList(params);
          this.commissionDatas=[];
          this.commissionDatas = commissions.items;
        },

        /* 保存编辑 */
        save() {

          this.$refs['form'].clearValidate();
          this.rules.recAmount = null;
          this.rules.bankAccountId = null;
          if(this.form.bankAccountId && !this.form.recAmount){
            this.rules.recAmount = [{required: true,message: '请输入收款金额',trigger: 'blur'}];
          }

          if(!this.form.bankAccountId && this.form.recAmount){
            this.rules.bankAccountId = [{required: true,message: '请选择收款账户',trigger: 'blur'}];
          }
          
          //校验必填信息
          this.$refs['form'].validate((valid) => {
            if (!valid) {return false;}

            this.form.preAmountCn = 0;
            if(this.form.preAmount && this.form.rate){
              this.form.preAmountCn = this.computeDirection ==1? (this.form.preAmount*this.form.rate).toFixed(4):(this.form.preAmount/this.form.rate).toFixed(4);
            }

            if(this.form.recAmount && this.form.rate){
              this.form.recAmountCn =this.computeDirection ==1?(this.form.recAmount*this.form.rate).toFixed(4):(this.form.recAmount/this.form.rate).toFixed(4);
            }

            if(this.form.items==null || this.form.items==undefined || this.form.items.length==0){
              this.$message.info('产品列表不能为空');
              return;
            }

            // var qty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.qty)  },0);
            // var surDeliverQty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.surplusDeliveryQty)  },0);
           

            // if(qty > surDeliverQty){
            //   this.$message.info("发货数量不能大于订单数量");
            //   return;
            // }

            CheckOutQty(this.form).then((d)=>{
              if(d.code === 200){
                this.loading = true;
                const saveOrUpdate = this.isUpdate == 2 ? UpdateSaleoutorder : AddSaleoutorder;
                saveOrUpdate(this.form)
                  .then((msg) => {
                    this.loading = false;
                    this.$message.success(msg);
                    this.updateVisible();
                  })
                  .catch((e) => {
                    this.loading = false;
                    this.$message.error(e.message);
                  });
              }else{
                this.$message.error(d.msg);
                return;
              }
            })
          });
        },

        audit(){
          this.$refs['form'].clearValidate();
          this.rules.recAmount = null;
          this.rules.bankAccountId = null;
          if(this.form.bankAccountId && !this.form.recAmount){
            this.rules.recAmount = [{required: true,message: '请输入收款金额',trigger: 'blur'}];
          }

          if(!this.form.bankAccountId && this.form.recAmount){
            this.rules.bankAccountId = [{required: true,message: '请选择收款账户',trigger: 'blur'}];
          }
          
          //校验必填信息
          this.$refs['form'].validate((valid) => {
            if (!valid) {return false;}

            this.form.preAmountCn = 0;
            if(this.form.preAmount && this.form.rate){
              this.form.preAmountCn = this.computeDirection ==1? (this.form.preAmount*this.form.rate).toFixed(4):(this.form.preAmount/this.form.rate).toFixed(4);
            }

            if(this.form.recAmount && this.form.rate){
              this.form.recAmountCn =this.computeDirection ==1?(this.form.recAmount*this.form.rate).toFixed(4):(this.form.recAmount/this.form.rate).toFixed(4);
            }

            if(this.form.items==null || this.form.items==undefined || this.form.items.length==0){
              this.$message.info('产品列表不能为空');
              return;
            }

            // var qty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.qty)  },0);
            // var surDeliverQty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.surplusDeliveryQty)  },0);
           
            // console.log('surDeliverQty',surDeliverQty,'qty',qty)
            // if(qty > surDeliverQty){
            //   this.$message.info("发货数量不能大于订单数量");
            //   return;
            // }

            this.form.preAmountCn = 0;
            if(this.form.preAmount && this.form.rate){
              this.form.preAmountCn = this.computeDirection ==1?(this.form.preAmount*this.form.rate).toFixed(4):(this.form.preAmount/this.form.rate).toFixed(4);
            }

            if(this.form.recAmount && this.form.rate){
              this.form.recAmountCn = this.computeDirection ==1?(this.form.recAmount*this.form.rate).toFixed(4):(this.form.recAmount/this.form.rate).toFixed(4);
            }

            CheckOutQty(this.form).then((d)=>{
              if(d.code === 200){
              this.loadingAudit = true;
              CheckStock(this.form).then((d)=>{
                this.loadingAudit = false;
                if(d.code === 200){
                  AuitSaleoutorder(this.form)
                  .then((msg) => {
                    this.loadingAudit = false;
                    this.$message.success(msg);
                    this.updateVisible();
                  })
                  .catch((e) => {
                    this.loadingAudit = false;
                    this.$message.error(e.message);
                  });
                }else{
                  d.data.map((m)=>{
                    let index = this.form.items.findIndex((i)=>{ return i.productId == m.productId && i.deliveryWareHouseId == m.deliveryWareHouseId });
                    this.form.items[index].isred = true;
                  })

                  this.$nextTick(() => {
                    this.$refs.items.doLayout();
                  });

                  this.$message.info(d.msg);
                }

              }).catch((e)=>{
                this.loading = false;
                this.$message.error(e.message);
              });
              }else{
                this.$message.error(d.msg);
                return;
              }
            })
          }); 
        },

        unAudit(){
          this.loadingUnAudit = true;
          AntiSaleoutorder(this.form.id)
            .then((msg) => {
              this.loadingUnAudit = false;
              this.$message.success(msg);
              this.updateVisible();
            })
            .catch((e) => {
              this.loadingUnAudit = false;
              this.$message.error(e.message);
            });
        },

        setData(id){
          QuerySaleoutorderById(id)
            .then((res) => {
              this.form = res; 
              if(this.form.orderId){
                this.chooseSaleOrder = true;
              }

              if(this.form.items){
                this.form.items.map((m)=>{
                  m.isEdit = !this.chooseSaleOrder;
                  m.isred = false;
                })
              }
              this.changeCurrencyRate(res.currencyId);

              this.$nextTick(() => {
                this.$refs.items.doLayout();
              });
          });
        },

        OpenProductList(){
          this.showProductList =true;
        },

        OpenSaleOrder(){
          this.showSaleOrderList=true;
          this.rules.outOrderNo = [{required: false}];
        },

        OpenPrereviceItemList(){
          if(this.form.outOrderNo){
            this.showPrereviceItemList =true;
            this.current = {preNum:this.form.outOrderNo,customerId:this.form.customerId}
          }else{
            this.$message.info("请输入订单号");
            return ;
          }
        },

        reloadPrereviceItemList(prereviceItemData){
          this.form.prerevices = [];
          prereviceItemData.map((item)=>{
            this.form.prerevices.push({
              orderId:this.form.id,
              // batchNo:item.id,
              prereviceId:item.id,
              reviceDate:item.reviceDate,
              amount:item.amount,
              currencyId:item.currencyId,
              currencyDesc:item.currencyDesc,
              bankAccountId:item.bankAccountId,
              bankAccountDesc:item.bankAccountDesc,
              customerId:item.customerId,
              customerName:item.customerName,
              preNum:item.preNum,
              remark:item.remark,
            })
          });

          this.$nextTick(() => {
            this.$refs.prerevices.doLayout();
          });

          this.form.preAmount = this.form.prerevices.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount?cur.amount:0)  },0);

          this.setRecAmount();
        },

        reloadItemList(orderData){

          console.log('orderData',orderData)

          if(this.form.items==null || this.form.items ==undefined){
            this.form.items = [];
          }
          orderData.map((item)=>{

            this.form.items.push({
              orderId:this.form.id,
              productId:item.id,
              qty:0,
              price:0,
              unitId:item.unitId,
              amount:0,
              rate:this.form.rate,
              currencyId:this.form.currencyId,
              priceCn:0,
              amountCn:0,
              deliveryQty:0,
              deliveryWareHouseId:item.wareHouseId?item.wareHouseId:this.form.warehouseId,
              commissionId:item.commissionId,
              commissionType:item.commissionType,
              commissionName:item.commissionName,
              commissionMethod:item.commissionMethod,
              scale:item.scale,
              commissionAmount:0,
              commissionAmountCn:0,
              costPrice:item.purPrice,
              productCode:item.code,
              productName:item.name,
              productTypeId:item.typeId,
              spc:item.spc,
              unitDesc:item.unitDesc,
              remarks:item.remarks,
              isEdit:true,
            })
          });

          this.$nextTick(() => {
            this.$refs.items.doLayout();
          });
        },

        /* 回调销售订单 */
        async reloadSaleOrder(saleorder){

          this.form = saleorder;

          // let saleoutorder = await QuerySaleorderById(saleorder.id);

          // saleoutorder.preAmount = 0;
          // this.isPreAmount = false;
          // this.form = saleoutorder;
          // this.form.id = '';
          // this.form.status = null;//用状态判断过账按钮是否出现
          // this.form.orderId = saleorder.id;
          // saleoutorder.items.map((m,index)=>{
          //   if(m.surplusDeliveryQty>0){
          //     this.form.items[index].isEdit = false;
          //     this.form.items[index].orderItemId = m.id;
          //     this.form.items[index].scale = m.scale;
          //     this.form.items[index].rules = m.rules;
          //     this.form.items[index].qty = m.surplusDeliveryQty;
          //     this.form.items[index].commissionId = m.commissionId;
          //     this.form.items[index].commissionAmount = m.commissionAmount;
          //     this.form.items[index].commissionAmountCn = m.commissionAmountCn;
          //   }
          // });

          // this.form.items.map((m)=>{
          //     m.id = '';
          // });


          if(this.form.items!=null && this.form.items!=undefined && this.form.items.length>0){

            this.form.items.map((item)=>{
              item.amount = item.qty * item.price;
              this.changeCommissionType(item);
              item.amountCn =this.computeDirection ==1?(item.amount*this.form.rate).toFixed(4):(item.amount/this.form.rate).toFixed(4);
            });
            

            this.form.orderAmount = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.amount)  },0);
            this.form.qtyTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.qty)  },0);
            this.form.commissionAmountTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.commissionAmount)  },0);
            this.form.commissionAmountCnTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.commissionAmountCn)  },0);

            this.form.qtyTotal =this.form.qtyTotal.toFixed(2);
            this.form.orderAmount =this.form.orderAmount.toFixed(4);
            this.form.commissionAmountTotal =this.form.commissionAmountTotal.toFixed(4);
            this.form.commissionAmountCnTotal =this.form.commissionAmountCnTotal.toFixed(4);
            this.form.orderAmountCn =this.computeDirection ==1?(this.form.orderAmount*this.form.rate).toFixed(4):(this.form.orderAmount/this.form.rate).toFixed(4);
          
          }

          this.setPreAmount();

          let currentUser = getUser();
          this.$set(this.form,'operatorId',currentUser.accountId);
          this.$set(this.form,'operatorName',currentUser.accountName);

          this.chooseSaleOrder = true;
          this.$nextTick(() => {
            this.$refs.items.doLayout();
            this.$refs.prerevices.doLayout();
          });
        },

        //设置金额
        setAmount(row,index){

          if(row.surplusDeliveryQty < 0 && this.chooseSaleOrder){
            this.$message.info("发货数量不能大于订单数量");
            // row.qty = row.surplusDeliveryQty;
            return
          }else{

            if(row.price && row.qty){
              let q = parseFloat(row.qty);
              let p = parseFloat(row.price);
              row.amount = (p * q).toFixed(4);
            }

            if(row.amount && this.form.rate){
              let r = parseFloat(this.form.rate);
              let a = parseFloat(row.amount);
              row.amountCn =this.computeDirection ==1? (a * r).toFixed(4):(a / r).toFixed(4);
            }

            if(row.amountCn && row.qty){
              let rq = parseFloat(row.qty);
              let ra = parseFloat(row.amountCn);
              row.priceCn = this.computeDirection ==1?(ra * rq).toFixed(4):(ra / rq).toFixed(4);
            }

            if(row.amount && row.scale){
              let s = parseFloat(row.scale);
              let a = parseFloat(row.amount);
              row.commissionAmount = ((s * a)/100).toFixed(4);
            }

            if(row.commissionAmount && this.form.rate){
              row.commissionAmountCn =this.computeDirection ==1? (row.commissionAmount*this.form.rate).toFixed(4):(row.commissionAmount/this.form.rate).toFixed(4);
            }

            this.changeCommissionType(row);

            this.setCommissionAmountTotal();

          }
        },

        //汇率发生变化时,对应产品明细的相关数据发生变化
        setRate(){

          this.$refs.items.data.map((item)=>{
            item.amount = (item.price && item.qty)?(item.qty * item.price).toFixed(4):0;
            item.amountCn = 0;
            if(item.amount && this.form.rate ){
              item.amountCn = this.computeDirection == 1 ?(item.amount * parseFloat(this.form.rate)).toFixed(4):(item.amount / parseFloat(this.form.rate)).toFixed(4);
            }
            item.priceCn = (item.amountCn && item.qty)?(item.amountCn / item.qty).toFixed(4):0;

           //设置提成信息
           this.changeCommissionType(item);
          })

           
          this.setCommissionAmountTotal();
        },

        // 选择提成类型
        changeCommissionType(row){

          row.scale = 0;
          row.commissionId = '';
          row.commissionAmount = 0;
          row.commissionAmountCn = 0;
        
          if((row.commissionType===0 || row.commissionType===1) && this.form.currencyId ){
            let commission = this.commissionDatas.find((d)=>{
              return d.commissionType == row.commissionType && d.currencyId == this.form.currencyId
            });

            if(commission){
              // 按产品类型提成 
              if(commission.commissionType == 0 ){

                //同一产品类型才能提成
                if(row.productTypeId == commission.productTypeId){

                  // 按数量 1
                  if(commission.commissionMethod == 1){

                    row.scale = commission.scale;
                    row.commissionId =commission.id;
                    row.commissionAmount = ((row.qty? parseFloat(row.qty):0) * parseFloat(commission.scale));
                    row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                  }

                  //按比例 2
                  if(commission.commissionMethod == 2){
                    row.scale = commission.scale;
                    row.commissionId =commission.id;
                    row.commissionAmount = (((row.amount? parseFloat(row.amount):0) * parseFloat(commission.scale))/100).toFixed(4);;
                    row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                  }
                }
              }

              // 按销售数量提成 
              if(commission.commissionType == 1 ){

                // 按数量 1
                if(commission.commissionMethod == 1){

                  row.scale = commission.scale;
                  row.commissionId =commission.id;
                  row.commissionAmount = ((row.qty? parseFloat(row.qty):0) * parseFloat(commission.scale));
                  row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                }

                //按比例 2
                if(commission.commissionMethod == 2){
                  row.scale = commission.scale;
                  row.commissionId =commission.id;
                  row.commissionAmount = (((row.amount? parseFloat(row.amount):0) * parseFloat(commission.scale))/100).toFixed(4);;
                  row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                }
              }

            }
          }
        },

        // 清除提成类型
        clear(row){
          row.scale = 0;
          row.commissionAmount = 0;
          row.commissionAmountCn = 0;

          this.changeCommissionType(row);
          this.setCommissionAmountTotal();
        },

        //统计预收款
        setPreAmount(){
          this.form.preAmount = 0;
          if(this.form.prerevices!=null && this.form.prerevices!=undefined && this.form.prerevices.length>0){
            this.form.preAmount = this.form.prerevices.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount?cur.amount:0)  },0);
          }
        },
        /* 删除 */
        remove(_row, index) {
          // this.form.items.splice(index, 1);
          this.form.items = this.form.items.filter((c)=>{return c.productCode !=_row.productCode && c.productName != _row.productName});
          this.setCommissionAmountTotal();
        },
        
        /* 删除 */
        removePre(_row, index) {
          this.form.prerevices.splice(index, 1);
          this.setPreAmount();
        },

        //设置提成金额汇总
        setCommissionAmountTotal(){
          this.form.qtyTotal = 0;
          // this.form.recAmount = 0;
          // this.form.recAmountCn = 0;
          // this.form.disAmount = 0;
          // this.form.disAmountCn = 0;
          this.form.orderAmount = 0;
          this.form.orderAmountCn = 0;
          this.form.commissionAmountTotal = 0;
          this.form.commissionAmountCnTotal = 0;
          if(this.form.items!=null && this.form.items!=undefined && this.form.items.length>0){

            this.form.orderAmount = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.amount)  },0);
            this.form.qtyTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.qty)  },0);
            this.form.commissionAmountTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.commissionAmount)  },0);
            this.form.commissionAmountCnTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre)  + parseFloat(cur.commissionAmountCn)  },0);

            this.form.qtyTotal =this.form.qtyTotal.toFixed(2);
            this.form.orderAmount =this.form.orderAmount.toFixed(4);
            this.form.commissionAmountTotal =this.form.commissionAmountTotal.toFixed(4);
            this.form.commissionAmountCnTotal =this.form.commissionAmountCnTotal.toFixed(4);
            this.form.orderAmountCn =this.computeDirection ==1?(this.form.orderAmount*this.form.rate).toFixed(4):(this.form.orderAmount/this.form.rate).toFixed(4);

            this.setRecAmount();
          }
        },

        setRecAmount(){
          // this.form.recAmount = (this.form.orderAmount - this.form.disAmount).toFixed(4);
          this.form.recAmountCn = this.computeDirection ==1?(this.form.recAmount * this.form.rate).toFixed(4):(this.form.recAmount / this.form.rate).toFixed(4);

          if(this.form.disAmount){
            this.form.disAmountCn = this.computeDirection ==1?(this.form.disAmount*this.form.rate).toFixed(4):(this.form.disAmount/this.form.rate).toFixed(4);
          }

          this.checkAmount();
        },

        checkAmount(){

          // let totalamount = parseFloat(this.form.disAmount?this.form.disAmount:0) + parseFloat(this.form.recAmount?this.form.recAmount:0) + parseFloat(this.form.preAmount?this.form.preAmount:0);
          // let oamount = parseFloat(this.form.orderAmount?this.form.orderAmount:0)
          // if( totalamount > oamount){
          //   this.$message.info("收款金额+优惠金额+预收金额不能大于出库金额");
          //   return;
          // }

          if(this.form.recAmount && this.form.rate){
            this.form.recAmountCn =this.computeDirection ==1?(this.form.recAmount * this.form.rate).toFixed(4):(this.form.recAmount / this.form.rate).toFixed(4);
          }

          this.form.actAmount =  parseFloat(this.form.orderAmount?this.form.orderAmount:0) - parseFloat(this.form.preAmount?this.form.preAmount:0) -  parseFloat(this.form.recAmount?this.form.recAmount:0)-  parseFloat(this.form.disAmount?this.form.disAmount:0)
          if(this.form.actAmount && this.form.rate){
            this.form.actAmountCn =  this.computeDirection ==1? (this.form.actAmount*this.form.rate).toFixed(4):(this.form.actAmount/this.form.rate).toFixed(4);
          }

        },
        /* 更新visible */
        updateVisible() {
          removePageTab({ key: this.$route.path });
          reloadPageTab({ fullPath: '/businesshandling/saleoutmanger' });
        },

        handleClose() {
          removePageTab({ key: this.$route.path });
          this.$router.push('/businesshandling/saleoutmanger');
        },

        //设置币种
        setDefaultCurreny(){
          // C-HB03
          QueryAllChildDictViewByCode(this.Constant.C_HB).then((d)=>{

            d.map((item)=>{
              if(item.code == 'C-HB03'){
              this.form.currencyId = item.id;
              this.changeCurrencyRate(item.id);
            }
            })
          });
        },

        changeBank(val){
          let bank = this.bankAccountDatas.find((b)=>{ return b.id == val});
          if(bank){
            this.form.bankAccount = bank.name;
          }
        },

         /* 选择币种 */
        changeCurrencyRate(val){
          this.$set(this.form,'rate',1);
          QueryModelByScurrencyId(val).then((res)=>{
            if(res){
              this.$set(this.form,'rate',res.rate);
              this.computeDirection = res.computeDirection;
            }
            this.setRate();
          });
        },

        dateFormat(row,column,cellValue){
          return moment(cellValue).format("YYYY-MM-DD");
        },

        // 单元格背景色
        cellStyle({ row, column, rowIndex, columnIndex }) {
          let cellStyle;
          switch (row.isred) {
            case true:
              cellStyle = 'color:#000000; background-color: #f1552a';
            break;
            default:
              cellStyle = '';
            break;
          }
          return cellStyle
        },

        /* 合计 */
        getSummaries(param){
          const sums = [];
          sums[0] = '合计' ;
          const { columns, data } = param;
          columns.forEach((column, index) => {
            if(index ==6){
              sums[index] = Number(this.form.qtyTotal).toFixed(2);
            }else if(index ==8){
              sums[index] = Number(this.form.orderAmount).toFixed(4);
            }else if(index ==10){
              sums[index] = Number(this.form.orderAmountCn).toFixed(4);
            }else if(index ==14){
              sums[index] = Number(this.form.commissionAmountTotal).toFixed(4);
            }else if(index ==15){
              sums[index] = Number(this.form.commissionAmountCnTotal).toFixed(4);
            }
          });




          this.$nextTick(() => {
            this.$refs.items.doLayout();
          });
          return sums;
        },

        /* 合计 */
        getSummariesPre(param){
          const sums = [];
          sums[0] = '合计' ;
          const { columns, data } = param;
          columns.forEach((column, index) => {
            if(index ==3){
              sums[index] =  Number(this.form.preAmount).toFixed(4);
            }
          });

          this.$nextTick(() => {
            this.$refs.prerevices.doLayout();
          });
          return sums;
        },

        /* 样式 */
        cellStylePre(param){
          const { row, column, rowIndex, columnIndex } = param;
          if(columnIndex==2){
            return{
              color:''
            }
          }
        },

        // 打印
        print(){
          PrintSaleOutOrderById(this.form.id).then((data)=>{
            const pWindow = printHtml({
                html: data, // 要打印的内容
                // style: '<style>span { color: red; }</style>',  // 页面样式
                // title: '', // 页面标题，浏览器打印设置显示页眉会显示页面标题
                horizontal: true, // 是否横向打印
                blank: true, // 是否打开新页面打印
                close: true, // 如果是打开新页面，打印完是否关闭
                print: true, // 如果是打开新窗口是否自动打印
                iePreview: true, // 是否兼容 ie 打印预览
                loading: true, // 是否显示 loading
                before: () => { // 打印开始的回调
                },
                done: () => { // 打印完成的回调
                },
                margin: 0, // 页间距
                header: '', // 页眉 html
                footer: '' // 页脚 html
            });
          });
        },
    },
     
      /* 监听visible属性变化 */
      watch: {
        visible(visible) {
          if (visible) {
            this.chooseSaleOrder = false;
            if (this.data && this.data.id) {
              //赋值this.form
              this.setData(this.data.id);
              this.isUpdate = this.data.id !=null && this.data.id !=undefined;
            } else {
              this.form={operatorId:'',orderDate:'',orderAmount:0,disAmount:0,recAmount:0,preAmount:0};
              this.isUpdate = false;
              let currentUser = getUser();
              this.$set(this.form,'orderDate',this.defaultDate);
              this.$set(this.form,'operatorId',currentUser.accountId);
              this.$set(this.form,'operatorName',currentUser.accountName);
              this.setDefaultCurreny();
            }
          } else {
              this.$refs['form'].clearValidate();
              this.form ={operatorId:'',orderDate:'',orderAmount:0,disAmount:0,recAmount:0,preAmount:0};
              let currentUser = getUser();
              this.$set(this.form,'orderDate',this.defaultDate);
              this.$set(this.form,'operatorId',currentUser.accountId);
              this.$set(this.form,'operatorName',currentUser.accountName);
              this.setDefaultCurreny();
          }
        }
      }
    };
  </script>
  <style lang="scss" scoped>
   /*总计字体颜色
   ::v-deep .el-table__footer-wrapper tbody td {
      color: var(--color-primary);
      cursor: pointer;
    }*/
  </style>